package com.shine.app.commons;

import java.util.Comparator;

public class SortString implements Comparator<String> {

	private int state;

	public SortString() {
	}

	public SortString(int state) {
		this.state = state;
	}

	public int compare(String string1, String string2) {
		if (state == Commons.SORT_DOWM) {
			return sortDown(string1, string2);
		}
		return sortUp(string1, string2);
	}

	private int sortUp(String string1, String string2) {
		if (string1.compareTo(string2) < 0) {
			return -1;
		} else if (string1.compareTo(string2) > 0) {
			return 1;
		} else {
			return 0;
		}
	}

	private int sortDown(String string1, String string2) {
		if (string1.compareTo(string2) > 0) {
			return -1;
		} else if (string1.compareTo(string2) < 0) {
			return 1;
		} else {
			return 0;
		}
	}
}
